from flask_restful import fields


ORDER_LIST_MARSHAL = {
    'pageniation': fields.Nested({
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'total': fields.Integer
    }),
    'list': fields.List(fields.Nested({
        'create_time': fields.String(attribute=lambda x: x.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.strftime('%Y/%d/%m %H:%M:%S')),
        'pay_number': fields.String(attribute=lambda x: str(x)),
        'pay_channels': fields.String(attribute=lambda x: '微信' if x == 1 else '支付宝'),
        'is_pay': fields.Boolean,
        'order_number': fields.String,
        'is_use': fields.Boolean,
        'pay_time': fields.String(attribute=lambda x: x.strftime('%Y/%d/%m %H:%M:%S'))

    }))
}

FrontUseOnerFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.Nested({
        'id': fields.Integer,
        'login_name': fields.String,
        'nick_name': fields.String,
        'avatar': fields.String,
        'is_distribution': fields.Boolean,
        'qrcode':fields.String,
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
    },  default={})
}
FrontUseListrFields = {
    'code': fields.Integer,
    'msg': fields.String,
    'data': fields.List(
        fields.Nested({
            'id': fields.Integer,
            'login_name': fields.String,
            'nick_name': fields.String,
            'avatar': fields.String,
            'is_distribution': fields.Boolean,
            'qrcode':fields.String,
            'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
            'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
        },  default={})
    )
}



SettingFields = {
    'code':fields.Integer,
    'msg':fields.String,
    'data':fields.Nested({
        'qq_number':fields.String,
        'logo':fields.String,
        'wechat_number':fields.String,
        'wechat_qrcode':fields.String,
        'level_1_price':fields.String,
        'level_1':fields.String,
        'level_2_price':fields.String,
        'level_2':fields.String,
        'level_3_price':fields.String,
        'level_3':fields.String,
    },default={})
}


TransferHistoryFields = {
    'code':fields.Integer,
    'msg':fields.String,
    'page': fields.Nested({
        'total': fields.Integer,
        'current': fields.Integer,
        'pageSize': fields.Integer,
        'totalPage': fields.Integer
    }),
    'data':fields.Nested({
        'create_time': fields.String(attribute=lambda x: x.create_time.strftime('%Y/%d/%m %H:%M:%S')),
        'update_time': fields.String(attribute=lambda x: x.update_time.strftime('%Y/%d/%m %H:%M:%S')),
        'transfer_number':fields.String,
        'is_transfer'   :fields.Boolean,
        'transfer_id'  :fields.String,
        'alipay_account'  :fields.String,
        'transfer_time'  :fields.String,
        'user':fields.String(attribute=lambda x:x.user.login_name),
    },default={})
}